package com.homework.str;

public class test4 {
  public static void main(String[] args) {
    // 计算字符串“ I love Java “首尾共有多少个空白字符
    String s = "I love Java";
    char[] carr = s.toCharArray();
    int count = 0;
    for (char c : carr) {
      if (String.valueOf(c).isBlank()) {
        count += 1;
      }
    }
    System.out.println(count);
  }
}
